<?php include '../public/header.php' ?>
<?php include '../public/header_public.php' ?>
<body class="laytp-container">
<div style="height: 45px"></div>
<div id="opt_nav">
</div>
<div id="dialog">
    <div class="page-title" id="page-title">
        <div class="page-title-con">
            <span class="title">联营项目经营情况表</span>
            <div class="move_title"></div>
            <div class="page-title-opt-list">
                <span id="page-close" class="page-close" onclick="layer_close()">×</span>
            </div>
        </div>
    </div>
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" id="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目状态：</label>
                        <div class="layui-input-block">
                            <select id="state" name="state" lay-filter="state">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>

    var param_name = decodeURI(getQueryVariable('name') || '') || '';
    if(param_name){
        $("#name").val(param_name);
        $("#name").prop('disabled', true);
        $("#name").addClass('disabled');
    }

    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('联营项目经营情况表');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_jing_lian_tong),where: {name:param_name}, page: true
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {

                xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                var state_str = '<option value="">请选择</option>';
                var state = res.data.state;
                for (var key in state){
                    if(res.data.is_state == key){
                        state_str += '<option value="'+key+'" selected>'+state[key]+'</option>';
                    }else {
                        state_str += '<option value="'+key+'">'+state[key]+'</option>';
                    }

                }
                $("#state").html(state_str);

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field: 'name', title: '项目名称'}
                ,{field: 'state_name', title: '项目状态'}
                ,{field: 'dutyer', title: '内包责任人'}
                ,{field:'shimoney',title:'施工合同(含变更)',totalRow: true,align:'right',event: 'contract_shi',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.shimoney)+'</span>';
                    }}
                ,{field: 'lei_chan', title: '累计审定产值',totalRow: true,align:'right',event: 'engin_chan',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_chan)+'</span>';
                    }}
                ,{field: 'lei_piaokai', title: '累计开票',totalRow: true,align:'right',event: 'piao_kai',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_piaokai)+'</span>';
                    }}
                ,{field: 'lei_huikuan', title: '项目收款 A',totalRow: true,align:'right',event: 'income_engin',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_huikuan)+'</span>';
                    }}
                ,{field: 'lei_piaoshou', title: '累计收票',totalRow: true,align:'right',event: 'piao_shou',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_piaoshou)+'</span>';
                    }}
                ,{field: 'lei_payment_engin', title: '项目付款(供应商) B',totalRow: true,align:'right',event: 'payment_engin',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_payment_engin)+'</span>';
                    }}
                ,{field: 'lei_payment_bao', title: '项目费用报销 C',totalRow: true,align:'right',event: 'payment_bao',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_payment_bao)+'</span>';
                    }}
                ,{field: 'lei_payment_neikou', title: '内包扣款 D',totalRow: true,align:'right',event: 'payment_neikou',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_payment_neikou)+'</span>';
                    }}
                ,{field: 'lei_payment_neifu', title: '内包付款 E',totalRow: true,align:'right',event: 'payment_neifu',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_payment_neifu)+'</span>';
                    }}
                ,{field: 'balance', title: '项目余额 A-B-C-D-E',totalRow: true,align:'right',templet: function(d){
                        if(d.balance < 0){
                            return '<span class="colorhong">'+parseFormatNum(d.balance)+'</span>';
                        }else{
                            return parseFormatNum(d.balance);
                        }

                    }}
                ,{field: 'chanid_name', title: '项目所属单位'}
            ]]
            , done: function (res) {
                soulTable.render(this);
            }
        });


        table.on('tool(datalist)',function (obj) {
            var data = obj.data;
            if(obj.event === 'contract_shi'){
                openPage('../contract_shi/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'engin_chan'){
                openPage('../engin_chan/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'piao_kai'){
                openPage('../piao_kai/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'income_engin'){
                openPage('../income_engin/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'piao_shou'){
                openPage('../piao_shou/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'payment_engin'){
                openPage('../payment_engin/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'payment_bao'){
                openPage('../payment_bao/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'payment_neikou'){
                openPage('../payment_neikou/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'payment_neifu'){
                openPage('../payment_neifu/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
        });

        listTableSearch(form, table);
    });




</script>
</body>
</html>
